﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using DA;
using BO;

namespace DoAnLTUD.WebUserControl
{
    public partial class ThemSanPham : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            SanPhamData data = new SanPhamData();
            SanPhamDB db = new SanPhamDB();
            data.MaSP = "SP" + DateTime.Now.ToString("ddMMyyHHmmss");
            data.TenSP = txtTenSanPham.Text;
            data.Gia = Decimal.Parse(txtGia.Text);
            data.ThongTin = txtThongTin.Text;
            data.MaLoai = Int32.Parse(dropMaLoai.SelectedValue);
            data.Sl = Int32.Parse(txtSoLuong.Text);
            data.HinhAnh = fileUploadHinhAnh.FileName;
            string path = Server.MapPath("~/images/");
            fileUploadHinhAnh.SaveAs(path+data.HinhAnh);
            data.MaNXS = Int32.Parse(dropMaNhaSanXuat.SelectedValue);
            data.GiaNhap = Int32.Parse(txtGiaNhap.Text);
            data.TinhTrang = txtTinhTrang.Text;
            db.ThemSanPham(data);
        }

        protected void btnHuy_Click(object sender, EventArgs e)
        {
            
        }
    }
}